/*-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in
compliance with the License.You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html
	
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific language governing rights and limitations
under the License.
	
The Original Code is Fever RS ( ActionScript 3 ) Framework code.
	
The Initial Developer of the Original Code is Romain Ecarnot.
Portions created by Initial Developer are Copyright (C) 2006
the Initial Developer. All Rights Reserved.
	
Contributor(s):
	
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-----------------------------------------------------------------------------*/

package fever.utils 
{
	import flash.geom.Matrix;		
	/**
	 * Drawing methods.
	 * 
	 * @author Romain Ecarnot
	 */
	final public class GraphicUtil 
	{
		//--------------------------------------------------------------------
		// Public API
		//--------------------------------------------------------------------
		
		/**
		 * Returns a horizontal gradient matrix defined by 
		 * passed-in arguments.
		 * 
		 * @param x X coordinate of the starting point of gradient
		 * @param y Y coordinate of the starting point of gradient
		 * @param width Width of the gradient
		 * @param height Height of the gradient
		 * @return a flash.geom.Matrix instance
		 */
		public static function getHorizontalGradientMatrix(
									x : Number, y : Number,
									width : Number, height : Number) : Matrix
		{
			return getRotatedGradientMatrix( x, y, width, height, 0 );
		}

		/**
		 * Returns a vertical gradient matrix defined by passed-in arguments.
		 * 
		 * @param x X coordinate of the starting point of gradient
		 * @param y Y coordinate of the starting point of gradient
		 * @param width Width of the gradient
		 * @param height Height of the gradient
		 * @return a flash.geom.Matrix instance
		 */
		public static function getVerticalGradientMatrix(
									x : Number, y : Number,
									width : Number, height : Number) : Matrix
		{
			return getRotatedGradientMatrix( x, y, width, height, 90 );
		}

		/**
		 * Returns a gradient matrix defined by passed-in arguments.<br />
		 * Gradient is rotate by passed-in {@code rotation} angle.
		 * 
		 * @param x X coordinate of the starting point of gradient
		 * @param y Y coordinate of the starting point of gradient
		 * @param width Width of the gradient
		 * @param height Height of the gradient
		 * @param rotation Gradient rotation angle
		 * @return a flash.geom.Matrix instance
		 */
		public static function getRotatedGradientMatrix(
									x : Number, y : Number,
									width : Number, height : Number,
									rotation : Number) : Matrix
		{
			var m : Matrix = new Matrix( );
			m.createGradientBox( 
				width, 
				height, 
				rotation * Math.PI / 180, 
				x, 
				y 
			);
			return m;
		}
		
		
		//--------------------------------------------------------------------
		// Private implementations
		//--------------------------------------------------------------------
				
		/** @private */
		public function GraphicUtil( acess : PrivateConstructorAccess ) 
		{
		}
	}
}


internal class PrivateConstructorAccess 
{
}